package File;

import java.io.File;
import java.io.IOException;

public class File01 {
    public static void main(String[] args) throws IOException {
        File file1 = new File("E:\\知识学习\\JAVA学习路线.txt");
        System.out.println(file1.exists()); // true
        File file2 = new File("E:\\");

        //创建文件
//        File file3 = new File("E:\\test.txt");
//        System.out.println(file3.createNewFile()); // false
        //使用list()方法遍历目录
        String[] list = file2.list();
        for (String s : list) {
            System.out.println(s);
        }
        //遍历目录
        for (File file : file2.listFiles()) {
            System.out.println(file);
        }
    }
}
